/*
 * AVectorField.java
 *
 * Created on October 29, 2008, 6:51 AM
 */

package curro;

import sequor.control.NumberSlider;
import specto.euclidean2.DESolution2D;
import specto.euclidean2.Parametric2D;
import specto.euclidean2.VectorField2D;

/**
 *
 * @author  ae3263
 */
public class AVectorField extends javax.swing.JApplet {

    /** Initializes the applet AVectorField */
    public void init() {
        try {
            java.awt.EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    initComponents();
                    String[] vars1={"x", "y"};
                    functionPanel1.setFunction(0, "P(x,y)=", "x*y-.1", vars1);
                    functionPanel1.setFunction(1, "Q(x,y)=", "cos(x)", vars1);
                    VectorField2D vf1=new VectorField2D(functionPanel1.getFunctionModel(0),functionPanel1.getFunctionModel(1));                        
                    
                    plot2D1.add(vf1);
                    DESolution2D des = new DESolution2D(vf1);
                    des.setVisible(false);
                    plot2D1.add(des);
                    plot2D1.add(vf1.getStyleSlider("Field style",0,0),5,5);

                    String[] vars2={"t"};
                    functionPanel2.setFunction(0, "x(t)=", "cos(t)+3", vars2);
                    functionPanel2.setFunction(1, "y(t)=", "sin(t)+3", vars2);
                    Parametric2D pp = new Parametric2D(functionPanel2.getFunctionModel(0),functionPanel2.getFunctionModel(1));
                    pp.setVisible(false);
                    pp.setAnimationOn(false);
                    plot2D1.add(pp);
                    
                    plot2D1.getVisometry().setDesiredBounds(-3,-3,3,3);
                }
            });
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /** This method is called from within the init() method to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        vectorField2D1 = new specto.euclidean2.VectorField2D();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jSplitPane1 = new javax.swing.JSplitPane();
        jTabbedPane2 = new javax.swing.JTabbedPane();
        functionPanel1 = new sequor.component.FunctionPanel(2);
        functionPanel2 = new sequor.component.FunctionPanel(2);
        plot2D1 = new specto.euclidean2.Plot2D();

        jSplitPane1.setDividerLocation(100);
        jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jTabbedPane2.addTab("Vector Field", functionPanel1);
        jTabbedPane2.addTab("Curve", functionPanel2);

        jSplitPane1.setLeftComponent(jTabbedPane2);

        plot2D1.setAxisStyle(1);

        javax.swing.GroupLayout plot2D1Layout = new javax.swing.GroupLayout(plot2D1);
        plot2D1.setLayout(plot2D1Layout);
        plot2D1Layout.setHorizontalGroup(
            plot2D1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 518, Short.MAX_VALUE)
        );
        plot2D1Layout.setVerticalGroup(
            plot2D1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 286, Short.MAX_VALUE)
        );

        jSplitPane1.setRightComponent(plot2D1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 392, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private sequor.component.FunctionPanel functionPanel1;
    private sequor.component.FunctionPanel functionPanel2;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTabbedPane jTabbedPane2;
    private specto.euclidean2.Plot2D plot2D1;
    private specto.euclidean2.VectorField2D vectorField2D1;
    // End of variables declaration//GEN-END:variables

}
